package com.example.lanouhn.bantangapp.activities.utils;



import com.example.lanouhn.bantangapp.activities.contants.Search_deildelist;
import com.example.lanouhn.bantangapp.activities.contants.Useroriginal;

import org.json.JSONArray;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.List;

/**
 * 解析Json数据
 */
public class JsonUtils_Search_deillist {

    /**
     * @param json json字符串
     * @return 搜索框下的清单数据
     */
    public static List<Search_deildelist> getsrachdeList(String json) {
        List<Search_deildelist> list = new ArrayList<>();
        try {
            JSONObject jsonObject = new JSONObject(json);

            JSONArray jsonArray = jsonObject.getJSONArray("data");

            for (int i = 0; i < jsonArray.length(); i++) {
                JSONObject j = jsonArray.getJSONObject(i);


                Search_deildelist m = new Search_deildelist();
                m.setId(j.getInt("id"));
                m.setName(j.getString("name"));
                m.setEn_name(j.getString("en_name"));
                m.setIcon(j.getString("icon"));
                list.add(m);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return list;
    }


}